@jmarcelino
Once again, thanks for the great feedback. I was looking for a simple way to alert when the battery needs to be recharged. Looks like some simple logic could be: if voltages gets to 3.3, alert for recharge...
So many LiPo batteries have differing characteristics, even among the same model/make/capacity/manufacturer. I don't think there is real value is tracking a percentage... without extensive battery testing. Simplest thing to do is just report voltage.
From the example from HERE do you recommend using the following:
numADCreadings = const(100)
def ADCloopMeanStdDev():
adc = machine.ADC(0)
adcread = adc.channel(attn=1, pin='P16')
samplesADC = [0.0]*numADCreadings; meanADC = 0.0
i = 0
while (i < numADCreadings):
adcint = adcread()
samplesADC[i] = adcint
meanADC += adcint
i += 1
meanADC /= numADCreadings
varianceADC = 0.0
for adcint in samplesADC:
varianceADC += (adcint - meanADC)**2
varianceADC /= (numADCreadings - 1)
print("%u ADC readings :\n%s" %(numADCreadings, str(samplesADC)))
print("Mean of ADC readings (0-1023) = %15.13f" % meanADC)
print("Mean of ADC readings (0-1400 mV) = %15.13f" % (meanADC*1400/1024))
print("Variance of ADC readings = %15.13f" % varianceADC)
print("10**6*Variance/(Mean**2) of ADC readings = %15.13f" % ((varianceADC*10**6)//(meanADC**2)))
print("ADC reading for Voltage (0-1400 mV) = %15.4f" % (meanADC*1400/1024))
From the ACD pin 16 voltage, the voltage is the meanACD*1400/1024
Does not seem right, the output is 4966.3634.